﻿import mx.utils.Delegate;

import com.mixmedia.motion.MotionTween;
import com.mixmedia.mx.AbstractMovieClipEventDispatcher;
import com.mixmedia.mx.events.EventButton;
import com.mixmedia.mx.IEventDispatcher;
/**
 * @author Colin
 */
class com.fangmeiti.control.PlayerOverlay extends AbstractMovieClipEventDispatcher implements IEventDispatcher{
	private var mcBG:MovieClip;
	private var mcIcon:MovieClip;
	private var mcLabel:MovieClip;
	private var mcCircle:MovieClip;
	private var bgMotion:MotionTween;
	private var motion : MotionTween;
	private var isHide : Boolean=false;

	private var xs : Number= 100;
	private var ys : Number= 100;
	
	public function PlayerOverlay(){
		motion = new MotionTween(this,{dur:10});
		bgMotion = new MotionTween(mcBG,{dur:10});
		mcBG.onRelease = Delegate.create(this,release);
		mcBG.onRollOver = Delegate.create(this,over);
		mcBG.onRollOut = Delegate.create(this,out);
	}
	
	private function release(){
		dispatchEvent(new EventButton(this,EventButton.EVENTRELEASE));
	}

	private function over(){
		bgMotion.startTween({a:1});
		dispatchEvent(new EventButton(this,EventButton.EVENTROLLOVER));
	}

	private function out(){
		bgMotion.startTween({a:100});
		dispatchEvent(new EventButton(this,EventButton.EVENTROLLOUT));
	}
	
	public function fullScreen(w:Number,h:Number){
		xs = w/_width*100;
		ys = h/_height*100;
		if(isHide==false){
			_xscale = xs;
			_yscale = ys;
			motion.startTween({a:100,dur:10,xs:xs,ys:ys});
		}
	}
	
	public function normalScreen(){
		xs = 100;
		ys = 100;
		if(isHide==false){
			_xscale = xs;
			_yscale = ys;
			motion.startTween({a:100,dur:3,xs:100,ys:100});
		}
	}
	
	public function hide(){
		if(isHide==false){
			_xscale = xs;
			_yscale = ys;
			motion.startTween({a:0,dur:10,xs:xs,ys:ys});
		}
		isHide=true;
	}
	
	public function show(){
		if(isHide==true){
			_xscale = xs;
			_yscale = ys;
			motion.startTween({a:100,dur:10,xs:xs,ys:ys});
		}
		isHide=false;
	}
}